package cn.tedu.controller;
//控制层controller
import cn.tedu.pojo.Car;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("car")
public class CarController {
    @RequestMapping("data")
    public String get(){
        System.out.println("我成功了");
        return "color";
    }
    @RequestMapping("car")
    public Car get2(){

        Car c = new Car(718,"保时捷", "Cayman T","红色", 641000.0);

        return c;
    }
    @RequestMapping("car2")
    public Car get3(){
        Car c = new Car();

        c.setId(718);
        c.setName("保时捷");
        c.setType("Cayman T");
        c.setColor("红色");
        c.setPrice(641000.0);

        return c;
    }
    //框架解析请求参数（get）id=1
    //解析（http://localhost:8070/car/add1?id=）
    @RequestMapping("add")
    public void add(Integer id){
        System.out.println("get方法测试"+id);
    }
    @RequestMapping("add2")
    public void add2(Integer id,String name){
        System.out.println("id="+id+"name"+name);
    }
    //解析（http://localhost:8070/car/add1?id=1&name=张三&color=red&type=BMW&price=9.9）
    @RequestMapping("add3")
    public Car add3(Car c){
        System.out.println(c);
        return c;
    }

}
